<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>

</head>
<body>

<div id="div1" >
    <input type="text" v-color="info">
</div>
<script>

    Vue.directive('color',{
        bind: function (element, info) {
            //修改元素的背景颜色
            // console.log(info);
            console.log(info.value.color1)
            element.style.backgroundColor = info.value.color2;
        },
    })
    const vueObj = new Vue({
        el: '#div1',
        data: {
            info:{                  //info 是一个对象
                color1: 'red',
                color2: 'pink',
                color3: 'yellow',


            }

        },
        methods: {
            handle: function() {

            }
        }
    });
</script>
</body>
</html>